import fs from "fs";
import path from "path";
import morgan from "morgan";

// 创建写入流
const accessLogStream = fs.createWriteStream(
  path.join(__dirname, "../../morgan.log"),
  { flags: "a" }
);

// 将日志写入文件方法
export default process.env.NODE_ENV === "production"
  ? morgan("combined", { stream: accessLogStream })
  : morgan("dev");
